from public import view_person

from pylib import models
from pylib import web

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class SetBirth(web.BaseHandler):
  @web.transaction_with_retries
  @web.model_from_request
  def SetBirth(self, person):
    person.death_year = self.int_or_none('year')
    person.death_month = self.int_or_none('month')
    person.death_day = self.int_or_none('day')
    person.put(request=self.request)

  @web.valid_xsrf_token_required
  def post(self):
    self.SetBirth()
    self.internal_redirect(view_person.ViewPerson())


application = webapp.WSGIApplication([('.*', SetBirth)])

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
